-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add /System/iOSSupport
to the library search path on Mac Catalyst
#121430
Conversation
I'm not opposed to this but it also seems less useful then the mirror for |
No, (Even worse is when you link frameworks that are present on both platforms, like I guess the user (or a library like |
r? shepmaster |
Unsure who has macOS/Xcode experience that I could assign this to. r? compiler |
Same r? compiler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can confirm this makes sense to do for the catalyst targets.
Then since you're back from vacation, I'll assign you to the PR ;) |
1cf90fc
to
d3dcb6e
Compare
This comment has been minimized.
This comment has been minimized.
d3dcb6e
to
ff3f0a3
Compare
Some changes occurred in src/tools/compiletest cc @jieyouxu |
☀️ Test successful - checks-actions |
Finished benchmarking commit (9782770): comparison URL. Overall result: ❌ regressions - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)This benchmark run did not return any relevant results for this metric. CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 676.092s -> 677.972s (0.28%) |
@madsmtm I'm currently auditing include directories passed to linkers and this is the only case in which rustc passes "system" directories, in other cases it leaves this work either to user or to cc/linker. Also, is it correct that these directories go after user-passed directories, but before other "system" directories implicitly passed by cc/linker (the linker flag order affects search order)? Seems generally reasonable. |
In the case of rust, most people expect that they can just run |
linker: Pass fewer search directories to the linker - The logic for passing `-L` directories to the linker is consolidated in a single function, so the search priorities are immediately clear. - Only `-Lnative=`, `-Lframework=` `-Lall=` directories are passed to linker, but not `-Lcrate=` and others. That's because only native libraries are looked up by name by linker, all Rust crates are passed using full paths, and their directories should not interfere with linker search paths. - The main sysroot library directory shouldn't generally be passed because it shouldn't contain native libraries, except for one case which is now marked with a FIXME. - This also helps with rust-lang#123436, in which we need to walk the same list of directories manually. The next step is to migrate `find_native_static_library` to exactly the same set and order of search directories (which may be a bit annoying for the `iOSSupport` directories rust-lang#121430 (comment)).
linker: Pass fewer search directories to the linker - The logic for passing `-L` directories to the linker is consolidated in a single function, so the search priorities are immediately clear. - Only `-Lnative=`, `-Lframework=` `-Lall=` directories are passed to linker, but not `-Lcrate=` and others. That's because only native libraries are looked up by name by linker, all Rust crates are passed using full paths, and their directories should not interfere with linker search paths. - The main sysroot library directory shouldn't generally be passed because it shouldn't contain native libraries, except for one case which is now marked with a FIXME. - This also helps with rust-lang#123436, in which we need to walk the same list of directories manually. The next step is to migrate `find_native_static_library` to exactly the same set and order of search directories (which may be a bit annoying for the `iOSSupport` directories rust-lang#121430 (comment)).
On macOS,
/System/iOSSupport
contains iOS frameworks like UIKit, which is the whole idea of Mac Catalyst.To link to these, we need to explicitly tell the linker about the support library stubs provided in the macOS SDK under the same path.
Concretely, when building a binary for Mac Catalyst, Xcode passes the following flags to the linker:
This is not something that can be disabled (it's enabled as soon as you enable
SUPPORTS_MACCATALYST
), so I think it's pretty safe to say that we don't need an option to turn these off.I've chosen to slightly deviate from what Xcode does and use
-F
instead of-iframework
, since we don't need to change the header search path, and this way the flags nicely match on all the linkers. From what I could tell by reading Clang sources, there shouldn't be a difference when just running the linker.CC @BlackHoleFox, @shepmaster (I accidentally let rustbot choose the reviewer).